package com.zc;

import com.zc.enums.MyEvent;
import com.zc.enums.MyState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.support.MyStateMachineUtils;

@SpringBootApplication
public class StateMachineInstanceStateApplication implements CommandLineRunner {
    @Autowired
    private StateMachine<MyState, MyEvent> stateMachine;

    public static void main(String[] args) {
        SpringApplication.run(StateMachineInstanceStateApplication.class, args);
    }

    @Override
    public void run(String... args){
        //stateMachine.sendEvent(MyEvent.E1);
        MyStateMachineUtils.setCurrentState(stateMachine,MyState.S1);
        stateMachine.sendEvent(MyEvent.E2);
    }
}
